home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / PRINT.ASM < prev    next >
Assembly Source File  |  1996-01-11  |  2KB  |  124 lines

  1. ; PRINT.ASM for E32 - Copyright (C) 1994 - 1996 Douglas Herr
  2. ;  all rights reserved
  3.  
  4. ; 01/07/1996 DH: added printer menu
  5.  
  6. include    model.inc
  7.  
  8. public    print, ffeed
  9. extrn    mark:near
  10. extrn    working:near
  11. extrn    ljsend:near
  12.  
  13. include    dataseg.inc
  14. extrn    breakflag:byte
  15. extrn    mark_start:dword, mark_end:dword, mark_mode:byte
  16. extrn    filesiz:dword
  17. extrn    int24h_msg:dword
  18. ff    db 12
  19. print_error    db 'Printer not ready or out of paper:  retry? (Y/N)',0
  20.  
  21. public    printer_type
  22. printer_type    db 0
  23.  
  24. setup_proc    dd offset CGROUP:ljsend
  25.         dd offset CGROUP:near_ret
  26.         dd offset CGROUP:near_ret
  27. @curseg    ends
  28.  
  29. include    codeseg.inc
  30. ;
  31. ; this subroutine sends a formfeed to the printer
  32. ; use DOS handle 4
  33. ;
  34. ffeed    proc    near
  35.     push    int24h_msg
  36.     mov    int24h_msg,offset print_error
  37.     call    working
  38.  
  39.     lea    edx,ff
  40.     mov    bx,4
  41.     mov    ah,40h
  42.     xor    ecx,ecx
  43.     inc    ecx
  44.     int    21h
  45.     jmp    exit            ; restore default error message
  46.  
  47. ffeed    endp
  48.  
  49. get_offset    equ    [ebp-4]
  50. bytes        equ    [ebp-8]
  51.  
  52. ;
  53. ; print the marked text
  54. ;
  55.  
  56. print:
  57.     push    int24h_msg
  58.     mov    int24h_msg,offset print_error
  59.  
  60. ; send setup string to printer
  61.     movzx    ebx,printer_type
  62.     call    setup_proc[ebx*4]
  63.  
  64. ; display 'Working' message
  65.     call    working
  66.     enter    8,0
  67.  
  68.     xor    eax,eax            ; default: print all
  69.     mov    ebx,filesiz
  70.  
  71.     cmp    mark_mode,0
  72.     je    short print0
  73.  
  74.     mov    ebx,mark_end
  75.     mov    eax,mark_start
  76.     sub    ebx,eax            ; bytes
  77.  
  78. print0:
  79.     mov    get_offset,eax
  80.     mov    bytes,ebx
  81.  
  82.     mov    breakflag,0
  83.  
  84. prn0:    shr    breakflag,1    ; check for ^C
  85.     jc    short print_done
  86.  
  87.     mov    eax,65535
  88.     cmp    eax,bytes
  89.     jbe    short prn1
  90.     mov    eax,bytes    ; print all remaining bytes
  91. prn1:    mov    ecx,eax        ; save bytes in ECX
  92.     jecxz    print_done    ; done if nothing to print
  93.  
  94. ; write to std output
  95. ; ECX = bytes to write
  96.     mov    edx,get_offset
  97.     push    ds
  98.     push    fs
  99.     pop    ds        ; DS:[EDX] -> working buffer
  100.     mov    bx,4        ; handle for 'PRN'
  101.     mov    ah,40h
  102.     int    21h
  103.     pop    ds
  104.     jc    short print_done
  105.  
  106.     add    get_offset,ecx
  107.     sub    bytes,ecx
  108.     jmp    prn0
  109.  
  110. print_done:
  111.     leave
  112.  
  113.     cmp    mark_mode,0
  114.     je    short exit
  115.     call    mark        ; turn off the mark state
  116.  
  117. exit:    pop    int24h_msg
  118.     clc
  119. near_ret:
  120.     ret
  121.  
  122. @curseg    ends
  123.     end
  124.